//
//  SearchMenuView.swift
//  Juejin App Demo
//
//  Created by 葛鹏 on 2021/8/15.
//

import SwiftUI

struct SearchMenuView: View {

    @Binding var searchTitleIndex: Int
    
    var body: some View {
        HStack(spacing: 20){
            
            ForEach(0..<Constants.menuTitles.count){index in
                
                if searchTitleIndex == index {
                    Button(action: {
                        searchTitleIndex = index
                    }, label: {
                        Text(Constants.menuTitles[index]).underline(true, color: Color.blue).foregroundColor(.blue)
                    })
                }else {
                    Button(action: {
                        searchTitleIndex = index
                    }, label: {
                        Text(Constants.menuTitles[index])
                    })
                }
            }
        }.foregroundColor(.gray)
    }
}

struct SearchMenuView_Previews: PreviewProvider {
    static var previews: some View {
        SearchMenuView(searchTitleIndex: .constant(0))
    }
}
